import { addUserData } from '../api/users'

export const state = () => {
    return {
        data: []
    }
}
export const mutations = {
    SET_LIST(state, v) {
        state.data = v.data
    }
}

export const actions = {
    async getData({ commit }) {
        console.log()
        const { data } = await this.$axios.get(
            "http://localhost:3001/users/user-list?pageSize=10"
        );
        commit('SET_LIST', data)
    },
    async addData({ }, row) {
        const r = await this.$axios.post('http://localhost:3001/users/save-user', row)
    },
    async editData({ }, row) {
        await this.$axios.post('http://localhost:3001/users/update-user', row)
    },
    async delData({ }, row) {
        console.log(row)
        await this.$axios.get(`http://localhost:3001/users/delete-user?id=${row}`)
    }
}

export const getters = {

}